﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogisticsBLL;
using Model;

namespace WebLosgic.Carress
{
    public partial class InsertCargo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int Carrid = Convert.ToInt32(Request.QueryString["CID"]);
                if (Carrid == 0)
                {
                    Response.Redirect("CarrierManage.aspx");
                }
            }
        }

        protected void BtnTian_Click(object sender, EventArgs e)
        {
            int Carrid = Convert.ToInt32(Request.QueryString["CID"]);
            Goods god = new Goods();
            god.GoodsName = TxtName.Text;
            god.Volume =Convert.ToInt32(TxtVolume.Text);
            god.Weight = Convert.ToInt32(TxtWeight.Text);
            god.FK_CarriersID = Carrid;
            god.Amount = Convert.ToInt32(TxtNumber.Text);
            CarriessCyBLL cb = new CarriessCyBLL();
            int result = cb.GoodsInsert(god);

            string name = Session["names"].ToString();
            string Behavor = "" + name + ": 添加货物";
            int TypeId = 24;
            int UserID = Convert.ToInt32(Session["UserIDs"]);
            string Parameters = @"" + TxtName.Text + "," + TxtVolume.Text;
            string ProcName = "insert into Carriers values(@SendCompany)";
            HttpRequest request = HttpContext.Current.Request;
            string IP = "192.168.0.1";
            int IsExcePion = 0;
            if (result > 0)
            {
                IsExcePion = 0;
                int a = ProcBLL.InserSys(Behavor, TypeId, UserID, Parameters, ProcName, IP, IsExcePion);
                Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('添加成功'); location.href='CarrierManage.aspx';", true);
            }
            else
            {
                IsExcePion = 1;
                int a = ProcBLL.InserSys(Behavor, TypeId, UserID, Parameters, ProcName, IP, IsExcePion);
                Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('添加失败')", true);
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("CarrierManage.aspx");
        }
    }
}